From: Owen W. Taylor Date: Tue, 5 Apr 2011 14:54:28 +0000 (-0400) Subject: StScrollbar: clean up properly when unmapped during scroll X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~8368 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=b9828bf5de710a44fd3fb3eed988ffb6730df0eb;p=gnome-shell.git StScrollbar: clean up properly when unmapped during scroll If we're unmapped (or destroyed) during a scroll, we want to clean up the changes we've made to Clutter's event handling, remove our signal handler, and emit ::scroll-stop. https://bugzilla.gnome.org/show_bug.cgi?id=646825 --- diff --git a/src/st/st-scroll-bar.c b/src/st/st-scroll-bar.c index 46c974d9c..3f67a27da 100644 --- a/src/st/st-scroll-bar.c +++ b/src/st/st-scroll-bar.c @@ -110,6 +110,8 @@ handle_button_press_event_cb (ClutterActor *actor, ClutterButtonEvent *event, StScrollBar *bar); +static void stop_scrolling (StScrollBar *bar); + static void st_scroll_bar_get_property (GObject *gobject, guint prop_id, @@ -271,6 +273,8 @@ st_scroll_bar_unmap (ClutterActor *actor) CLUTTER_ACTOR_CLASS (st_scroll_bar_parent_class)->unmap (actor); + stop_scrolling (ST_SCROLL_BAR (actor)); + clutter_actor_unmap (priv->bw_stepper); clutter_actor_unmap (priv->fw_stepper); clutter_actor_unmap (priv->trough); @@ -806,6 +810,22 @@ move_slider (StScrollBar *bar, st_adjustment_set_value (priv->adjustment, position); } +static void +stop_scrolling (StScrollBar *bar) +{ + ClutterActor *stage; + + if (!bar->priv->capture_handler) + return; + + stage = clutter_actor_get_stage (bar->priv->trough); + g_signal_handler_disconnect (stage, bar->priv->capture_handler); + bar->priv->capture_handler = 0; + + clutter_set_motion_events_enabled (TRUE); + g_signal_emit (bar, signals[SCROLL_STOP], 0); +} + static gboolean handle_capture_event_cb (ClutterActor *trough, ClutterEvent *event, @@ -822,19 +842,11 @@ handle_capture_event_cb (ClutterActor *trough, { ClutterActor *stage, *target; - stage = clutter_actor_get_stage(bar->priv->trough); - - if (bar->priv->capture_handler) - { - g_signal_handler_disconnect (stage, bar->priv->capture_handler); - bar->priv->capture_handler = 0; - } - - clutter_set_motion_events_enabled (TRUE); - g_signal_emit (bar, signals[SCROLL_STOP], 0); + stop_scrolling (bar); /* check if the mouse pointer has left the handle during the drag and * remove the hover state if it has */ + stage = clutter_actor_get_stage (bar->priv->trough); target = clutter_stage_get_actor_at_pos ((ClutterStage*) stage, CLUTTER_PICK_REACTIVE, ((ClutterButtonEvent*) event)->x, @@ -843,8 +855,6 @@ handle_capture_event_cb (ClutterActor *trough, { st_widget_remove_style_pseudo_class ((StWidget*) bar->priv->handle, "hover"); } - - } return TRUE;